package lxq.away3d.llight;

import flash.geom.Vector3D;

import away3d.containers.Scene3D;
import away3d.lights.DirectionalLight;
import away3d.lights.PointLight;
import away3d.materials.ColorMaterial;
import away3d.materials.lightpickers.StaticLightPicker;

import lxq.primitives.Ball;

class LightFactory{
public static var direcLight:DirectionalLight;
public static var pointLight:PointLight;

public static var lightPicker:StaticLightPicker;
public static function createDirecLight(scene:Scene3D,color:UInt=0xffffff,position:Vector3D=null,ambient:Float=.1,ambientColor:UInt=0xffffff,show:Bool=true):DirectionalLight{
	direcLight=new DirectionalLight();
	direcLight.color=color;
	direcLight.ambient=ambient;
	direcLight.ambientColor=ambientColor;
	if(position){
	direcLight.position=position;
	}
	direcLight.lookAt(new Vector3D());
	if(scene)scene.addChild(direcLight);
	if(show){
	var b:Ball=new Ball(10,10,10,new ColorMaterial(color));
	direcLight.addChild(b);
	}
	return direcLight;
}
public static function createPointLight(scene:Scene3D,color:UInt=0xffffff,position:Vector3D=null,ambient:Float=.1,ambientColor:UInt=0xffffff,show:Bool=true):PointLight{
	pointLight=new PointLight();
	pointLight.color=color;
	if(position)pointLight.position=position;
	pointLight.ambient=ambient;
	pointLight.ambientColor=ambientColor;
	if(show){
	var b:Ball=new Ball(10,10,10,new ColorMaterial(color));
	pointLight.addChild(b);
	}
	if(scene)scene.addChild(pointLight);
	return pointLight;
}
public static function createPicker(arr:Array):Void{
	lightPicker=new StaticLightPicker(arr);
}
public static var shadow(null, setShadow):Bool;
 	private function setShadow(value:Bool):Void{
	if(pointLight)pointLight.castsShadows=value;
	if(direcLight)direcLight.castsShadows=value;
}
}